const common = require('../../../public.js')
const utils = require('../../../utils/utils.js')
import Toast from '@vant/weapp/toast/toast';
const app = getApp()
Page({
    /**
     * 页面的初始数据
     */
    data: {
        isOverShare: true, //全局分享标识请勿删除
        arr: [],
        isShow: true,
        tabbarActive: 0,
        equityList: [],
        cardName:'',
        nianList: [],
        show: false,
        actions: [],
        showCancel: false, //注销
        showInvite: false,
        showCode: true,
        showServe: false, //客服
        activeIndex: 0,
        lineRight: '',
        distance: 0,
        lastX: 0, //滑动开始x轴位置
        text: "没有滑动",
        currentGesture: 0, //标识手势
        lineLeft: "",
        msgCode: '', //注销验证码
        speedValue: 8,
        NoticeFlag: true,
        showNotice: false,
        showCoup: false, //优惠券弹框
    },
    // 关闭
    // 订单

    fn() {
        this.setData({
            NoticeFlag: false
        })
    },
    onClickHideNotice() {
        this.setData({
            showNotice: false
        })
    },
    openNotice() {
        this.setData({
            showNotice: true
        })
    },
    // 关闭
    closeTan() {
        //  console.log("关闭123")
        this.setData({
            showInvite: false
        })
    },
    // 点击分类
    click_category(e) {
        var that = this
        let {
            index,
            item
        } = e.currentTarget.dataset
        console.log(index * 25)
        this.setData({
            activeIndex: index,
            lineRight: index * 25
        }, () => {
            that.Nian_ca(item.id)
        })

    },
    server_connection() {
        this.setData({
            showServe: true,
        })
    },

    getCode() {
        const that = this
        var myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
        const numy = myreg.test(this.data.userInfo.phone)
        if (numy) {
            const tempJson = {
                telephone: that.data.userInfo.phone,
                cardId: that.data.nianList[0].annualCardId,
                userId: that.data.userInfo.id,
                token: that.data.token,
                //  flag:MD5Utils.md5("LMC")
            }
            common.post('/userAnnualCard/sendLogoutMsgCode', tempJson, function (res) {
                if (res.status == 200) {
                    that.getCodes()
                    if (res.msg == 'OK') {
                        wx.showToast({
                            title: '发送成功',
                            icon: 'none'
                        })
                    }
                } else {
                    wx.showToast({
                        title: res.msg,
                        icon: 'none'
                    })
                }
            })

            return
        } else {
            wx.showToast({
                title: "请输入正确得手机号",
                icon: 'none'
            })
            return
        }
    },
    onChangeCode(e) {
        this.setData({
            msgCode: e.detail
        })
    },
    // 验证码
    getCodes() {
        const TIME_COUNT = 60;
        if (!this.data.timer) {
            this.setData({
                count: TIME_COUNT,
                showCode: false,
            })
            this.timer = setInterval(() => {
                if (this.data.count > 0 && this.data.count <= TIME_COUNT) {
                    this.data.count--
                    this.setData({
                        count: this.data.count
                    })
                    console.log(this.data.count)
                } else {
                    this.setData({
                        showCode: true
                    })
                    clearInterval(this.timer);
                    this.setData({
                        timer: null
                    })
                }
            }, 1000)
        }
    },

    // 查看详情
    toInviteDetail() {
        wx.navigateTo({
            url: '/packageC/pages/YearCardInvite/YearCardInviteDetail/YearCardInviteDetail?annualCardId=' +
                this.data.nianList[0].annualCardId +
                '&inviteNum=' + this.data.nianList[0].inviteNum,
        })
    },
    // 邀请
    click_invited() {
        if (this.data.nianList[0].isOpen == 1) {
            Toast.fail('活动未开启');
            return
        }
        this.setData({
            showInvite: true
        })
    },
    // 打开注销遮罩层
    click_cancel() {
        this.setData({
            showCancel: false
        });
    },
    click_open() {
        this.setData({
            showCancel: true
        });
    },
    // 确定注销
    cancelBtn() {
        var that = this
        if (!that.data.msgCode) {
            common.showToast('验证码不能为空！')
            return
        }
        common.get('/userAnnualCard/cancellationCard', {
            userId: that.data.userInfo.id,
            token: that.data.token,
            cardId: this.data.nianList[0].annualCardId,
            telephone: that.data.userInfo.phone,
            msgCode: that.data.msgCode
        }, res => {
            if (res.status === 200) {
                wx.redirectTo({
                    url: '/packageC/pages/packCard/packCard',
                })

            } else {
                common.showRequestErrMsg(res)
            }
        })
    },
    // onClickShow() {
    //     this.setData({
    //         showCancel: true
    //     });
    // },
    onClickHide() {
        this.setData({
            showCancel: false
        });
    },
    onClickHideServe() {
        this.setData({
            showServe: false
        });
    },
    onClickHideCoup() {
        this.setData({
            showCoup: false
        });
    },
    // 去首页
    toIndex() {

    },
    // 去卡包
    toCardPack() {
        this.setData({
            tabbarActive: 4
        })
        wx.redirectTo({
            url: '/packageC/pages/packCard/packCard',
        })
    },
    onClose() {
        this.setData({
            show: false
        });
    },
    toOrder() {
        wx.navigateTo({
            url: '/pages/ScenicArea/NianCardOrder/index',
        })
    },
    onSelect(event) {
        console.log(event, "5555")
        var name = event.detail
        // console.log(name.name,'jujehjjju')
        // console.log(this.data.actions[0])
        if (name.name == '呼叫') {
            // console.log("56612255")
            wx.makePhoneCall({
                phoneNumber: this.data.actions[0].name,
            })
        }
    },
    //   是否显示底部
    click_show() {
        this.setData({
            show: !this.data.show
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */

    goBack() {
        const pages = getCurrentPages();
        const prevPage = pages[pages.length - 2]; //上一个页面
        // 从朋友圈进入的时候，页面栈为空，这里需要判断是否有上个页面
        if (prevPage) {
            wx.navigateBack({
                delta: 1
            })
        } else {
            wx.redirectTo({
                url: '/pages/index/index',
            })
        }
    },

    // 权益类型
    typeList(id = null) {
        var that = this
        common.get('/store/getStoreTypeListForCard', {
            cardId: id
        }, res => {
            if (res.status === 200) {
                for (var i = 0; i < res.data.length; i++) {
                    res.data[i].id = res.data[i].id.toString()
                }
                if (res.data.length > 0) {
                    // that.cardsList_two(res.data[0].id) //调取权益列表
                } else {
                    // that.cardsList_two(kong) //调取权益列表
                }

                that.setData({
                    typeList: res.data
                }, () => {
                    if (that.data.nianList[0].showType == 1) {
                        that.Nian_ca()
                        // console.log(that.data.typeList, "少权益展示")
                        return
                    }
                    that.selectComponent('#tabs').resize();
                    that.Nian_ca(that.data.typeList[0].id)
                    // console.log(that.data.typeList, "南山南，北秋悲，南山有谷堆")
                })
            } else {
                common.showRequestErrMsg(res)
            }
        })
    },
    onClickss(event) {
        var that = this
        that.Nian_ca(event.detail.name)
    },

    reLists() {
        var that = this
        common.get('/userAnnualCard/getCardList', {
            cardId: that.data.nianList[0].annualCardId
        }, res => {
            if (res.status === 200) {

                for (var i = 0; i < res.data.length; i++) {
                    if (res.data[i].cardNotice)
                        res.data[i].cardNotice = res.data[i].cardNotice.replace(/<[^>]+>/g, "") //去除content里面的标签
                }
                that.setData({
                    cardNotice: res.data[0].cardNotice
                },
                    () => {

                    })
            } else {
                common.showRequestErrMsg(res)
            }
        })
    },
    inviteListIng() {
        let that = this
        common.get('/userAnnualCard/getShareNotCodeList', {
            cardId: that.data.nianList[0].annualCardId,
            userId: that.data.userInfo.id,
            token: that.data.token
        }, res => {
            if (res.status === 200) {
                console.log(res.data, "邀请中邀请中")
                that.setData({
                    inviteListIng: res.data
                })
            }
        })
    },
    // 判断是否支付
    isPay() {
        var that = this
        common.get('/userAnnualCard/checkUserBoughtCard', {
            userId: this.data.userInfo.id,
            cardId: this.data.cardId,
            token: this.data.token
        }, res => {
            console.log(res)
            if (res.status === 1) {
                common.showToast(res.msg)
                that.cardsList()
            }
        })
    },
    onLoad: function (opt) {
        var that = this
        //获取胶囊位置

        let capsule = wx.getMenuButtonBoundingClientRect()
        this.setData({
            height: capsule.height,
            top: capsule.top,
        })
        var windowHeight = wx.getSystemInfoSync().windowHeight
        var windowWidth = wx.getSystemInfoSync().windowWidth
        this.setData({
            scroll_height: windowHeight * 750 / windowWidth - 200
        })

        //  获取个人信息
        common.getLocalUserInfo(function (success, data) {
            if (success) {
                console.log(data, "ddddddd")
                that.setData({
                    userInfo: data.user,
                    token: data.token
                }, function () {
                    this.cardsList() //会员卡列表
                    // this.reLists()
                })
            } else {
                that.setData({
                    userInfo: null,
                    token: '',
                })
            }
        }, true)
        setTimeout(() => {
            this.setData({
                sho: true
            })
        }, 1000);
        console.log(opt, "8888888")
        // 从列表进来的时候
        if (opt.obj) {
            console.log(opt.obj, "opt.objopt.objopt.objopt.objopt.objopt.obj")
            var items = decodeURIComponent(opt.obj)
            console.log(items, "000000000000000000000000000000000000000000")
            this.setData({
                items
            }, () => {
             
                var obj = JSON.parse(this.data.items)
                console.log(obj,"lilllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll")
                wx.setStorageSync('obj', obj)
                this.setData({
                    YearId: obj.annualCardId,
                    cardName:obj.name
                })
            })

        } else {
            if (wx.getStorageSync('obj')) {
                var obj = wx.getStorageSync('obj')

                this.setData({
                    YearId: obj.annualCardId,
                    cardName:obj.name
                })
            }
        }

        if (opt.act) {
            this.setData({
                active: parseInt(opt.act)
            })
        }
    },

    handletouchtart(e) {
        this.setData({
            lastX: e.touches[0].pageX
        })
        // console.log(e.touches[0].pageX)
        // console.log("1111111111111111111111111")
    },
    // handletouchend(e){
    //     console.log(e.touches[0].pageX)
    //     console.log("结束结束结束")
    // },
    // handletouchmove(e) {
    //     var currentX = e.touches[0].pageX

    //     var tx = currentX - this.data.lastX
    //     var text = ""
    //     console.log(tx,"5555555")
    //     // 左右方向滑动
    //     if(tx < 0){  //左滑
    //       this.setData({
    //         lineRight:(this.data.activeIndex+1)*25,
    //         activeIndex:this.data.activeIndex+1

    //       })
    //     }else{   //右滑

    //     }
    //     //    this.setData({
    //     //     lineRight:"",
    //     //     activeIndex:0,
    //     //    })
    // },
    // 轮播切换获取数据
    getCurrent(e) {
        var that = this
        var id = e.detail.currentItemId
        var time = this.data.nianList.find(item => item.annualCardId == id)

        var arr = []
        arr.push({
            name: time.merchantPhone
        }, {
            name: "呼叫"
        })
        this.setData({
            id,
            cardImage: time.cardImage,
            times: time.validTime,
            actions: arr
        }, () => {
            // this.typeList(id)
            that.Nian_ca()
        })

    },
    // 我购买会员卡列表接口-------------------------------------------------------------------------------
    cardsList() {
        var that = this
        common.get('/userAnnualCard/getUserCardProductList', {
            userId: that.data.userInfo.id,
            token: that.data.token
        }, res => {
            console.log("进来了，654444444444444444444444444444")
            if (res.status === 200) {
                for (var i = 0; i < res.data.length; i++) {

                    res.data[i].validTime = that.time(res.data[i].validTime)
                    if (res.data[i].inviteEndTime) res.data[i].inviteEndTime = that.time(res.data[i].inviteEndTime)

                }
                console.log(that.data.YearId,"that.data.YearIdthat.data.YearId")
              
                var newArry = res.data.filter((item, index) => {
                    
                    return item.annualCardId == that.data.YearId
                })
                
                that.setData({
                    nianList: newArry
                }, () => {
                    if (that.data.nianList.length && that.data.nianList.length!=0) {
                        // 联系商家 
                        var arr = []
                        arr.push({
                            name: that.data.nianList[0].merchantPhone,
                        }, {
                            name: '呼叫',

                        })
                        this.reLists()
                        that.setData({
                            id: that.data.nianList[0].annualCardId,
                            times: that.data.nianList[0].validTime,
                            cardImage: that.data.nianList[0].cardImage,
                            merchantPhone: that.data.nianList[0].merchantPhone,
                            actions: arr
                        }, () => {

                            console.log(that.data.nianList[0], "4455126788888888888")

                            // that.cardsList(that.data.nianList[0].cardId)
                            that.typeList(that.data.nianList[0].annualCardId) //会员卡列表类型
                            that.inviteListIng()
                        })
                    }else{
                        if(that.data.items.annualCardId)
                        wx.navigateTo({
                          url: '/pages/myNian/payCard/payCard?cardId=' +that.data.items.annualCardId ,
                        })
                    }
                })
            } else {
                common.showRequestErrMsg(res)
            }
        })
    },
    // 时间戳
    time(time) {
        return common.dateFormat('yyyy-MM-dd', time)
    },
    // 会员卡可享权益
    Nian_ca(id = "") {
        var that = this
        common.get('/userAnnualCard/getCardProductListForApplets', {
            cardId: that.data.id,
            productType: id,
            userId: that.data.userInfo.id,
            token: that.data.token
        }, res => {
            console.log(res.data, "ceshishi")
            if (res.status === 200) {

                for (var i = 0, len = res.data.length; i < len; i++) {
                    res.data[i].discounts = res.data[i].discount
                    res.data[i].discount = (res.data[i].discount * 10).toFixed(1)
                    res.data[i].num_string = res.data[i].discount.toString()
                    if (res.data[i].num_string.indexOf('.') != -1) { //包含
                        res.data[i].len = res.data[i].num_string.split(".")[1]
                        res.data[i].newnum = 0
                        if (res.data[i].len != 0) {
                            res.data[i].newnum = res.data[i].discount
                        } else {
                            res.data[i].newnum = res.data[i].num_string.split(".")[0]
                        }

                    }
                }

                var newArr = res.data.map((item, index, arr) => {

                    // 进行判断 0门票预约 1 是会员卡商品 2 是会员卡优惠券商品
                    if (!item.cardProductType) {
                        if (item.nowOrderStatus == 1 && item.needReserve == 0) {
                            item.statusNames = '预约'
                            console.log("符合", item)
                        } else if (item.needReserve == 1 && item.nowOrderStatus == 1) {
                            item.statusNames = '去使用'
                        } else if (item.needReserve == 1 && item.nowOrderStatus == 10) {
                            item.statusNames = '去使用'
                        } else if (item.nowOrderStatus == 2 && item.needReserve == 0) {
                            item.statusNames = '去核销'
                        } else if (item.nowOrderStatus == 3 && item.needReserve == 0) {
                            // item.statusNames = '已过期'
                            item.statusNames = '预约'
                        } else if (item.nowOrderStatus == 5 && item.isCommented == 0) {
                            item.statusNames = '去评价'
                        } else if (item.nowOrderStatus == 5 && item.isCommented == 1) {
                            item.statusNames = '预约'
                        }
                        else if (item.nowOrderStatus == 6) {
                            // item.statusNames = '交易关闭'
                            item.statusNames = '预约'
                        } else if (item.nowOrderStatus == 7) {
                            // item.statusNames = '已退款'
                            item.statusNames = '预约'
                        } else if (item.nowOrderStatus == 8) {
                            // item.statusNames = '退款中'
                            item.statusNames = '预约'
                        } else if (item.nowOrderStatus == 9) {
                            item.statusNames = '出票中'
                        } else if (item.nowOrderStatus == 10 && item.needReserve == 0) {
                            item.statusNames = '预约'
                        } else if (item.nowOrderStatus == null && item.needReserve == 0) {
                            item.statusNames = '预约'
                        } else if (item.nowOrderStatus == null && item.needReserve == 1) {
                            item.statusNames = '去使用'
                        }
                        return item
                    } else if (item.cardProductType == 1) {
                        item.statusNames = '购买'
                        return item
                    } else if (item.cardProductType == 2) {
                        item.statusNames = '领取'
                        return item
                    }
                })

                if (that.data.id == 7) {
                    // var items = {
                    //     discount: 0, //免费
                    //     frequency: 12,
                    //     productName: "中国石油加油券（联系客服）",
                    //     singleValue: 15,
                    // }
                    var itemss = {
                        discount: 0, //免费
                        frequency: 1,
                        productName: "中国移动咪咕视频会员(联系客服)",
                        singleValue: 180,
                    }
                    res.data.unshift(itemss)
                }

                // newArr.push()
                that.setData({
                    nianLists: newArr
                }, () => {
                    console.log("下面的测试数据", that.data.nianLists)
                })
            } else {
                common.showRequestErrMsg(res)
            }
        })

    },
    // 去我的券包
    go_myCoup() {
        wx.navigateTo({
            // url: '/pages/ScenicArea/NianCardOrder/index?titles=2',
            url: '/pages/coupons/myCoupons/index'
        })
    },
    // 优惠券领取
    getCoup(cardId, productId, storeId) {
        var that = this
        const tempJson = {
            userId: that.data.userInfo.id,
            token: that.data.token,
            cardId: cardId,
            num: 1,
            couponId: productId,
            storeId: storeId,
        };

        //创建订单
        var url = '/cardCoupon/createOrder'
        common.post(url, tempJson, function (ret) {
            if (ret.status == 200) {
                that.setData({
                    showCoup: true
                })
                // wx.showToast({
                //     title: '支付成功',
                //     icon: 'none',
                //     success: res => {
                // setTimeout(() => {
                //     if (that.data.cardId) {
                //         wx.navigateTo({
                //             url: '/pages/ScenicArea/NianCardOrder/index?titles=2',
                //         })
                //     }
                // })
                //     }
                // })
            } else {
                common.showToast(ret.msg)
            }
        })

    },
    // 点击预约
    onClickShow(e) {
        var that = this
        var item = e.currentTarget.dataset.item
        this.setData({
            objs: e.currentTarget.dataset.item
        }, () => {
            // this.checkLoginToJump('/pages/realIdent/index')
            if (item.cardProductType == 1) {
                // if (this.data.userInfo.isRealname) { //判断是否实名
                    app.globalData.cardId = item.cardId
                    app.globalData.discount = item.discount
                    app.globalData.productprice = item.productPrice
                    // common.toRealName('/pages/realIdent/index')
                    // 购买的预约x
                    wx.navigateTo({
                        url: '/pages/goYuyue/yuYue/index?productId=' + that.data.objs.productId +
                            '&cardId=' + that.data.objs.cardId +
                            '&productType=' + that.data.objs.productType +
                            '&cardProductType=' + item.cardProductType +
                            '&productId=' + item.productId,
                    })

                // } else {
                //     common.toRealName('/pages/realIdent/index')
                // }
                return
            } else if (item.cardProductType == 2) {
                console.log(e, "74485477")
                console.log("44478888") //优惠券商品领取
                let {
                    cardId,
                    productId,
                    storeId
                } = e.currentTarget.dataset.item
                this.getCoup(cardId, productId, storeId)
                return
            }
            if (e.currentTarget.dataset.item.surplusUse == -1) {
                if (item.surplusUse == -1 && item.nowOrderStatus == 2 || item.surplusUse == -1 && item.nowOrderStatus == 5) {
                    if (item.nowOrderStatus == 1 && item.needReserve == 0 ||
                        item.nowOrderStatus == 3 && item.needReserve == 0 ||
                        item.nowOrderStatus == 6 && item.needReserve == 0 ||
                        item.nowOrderStatus == 7 && item.needReserve == 0 ||
                        item.nowOrderStatus == 8 && item.needReserve == 0) {
                        item.statusNames = '预约'
                        wx.navigateTo({
                            url: '/pages/goYuyue/yuYue/index?productId=' + that.data.objs.productId +
                                '&cardId=' + that.data.objs.cardId +
                                '&productType=' + that.data.objs.productType,
                        })
                    } else if (item.needReserve == 1 && item.nowOrderStatus == 1) {
                        item.statusNames = '去使用'
                        if (this.data.userInfo && this.data.userInfo.isRealname) {
                            wx.navigateTo({
                                url: '/packageA/pages/indexnian/qrcode/qrcode?cardId=' +
                                    item.cardId + '&productId=' +
                                    item.productId + '&imgCard=' + that.data.cardImage +
                                    '&imgurl=' + item.productImage +
                                    '&productName=' + item.productName +
                                    '&pid_name=' + item.pid_name +
                                    '&productType=' + item.productType,
                            })
                        } else {
                            this.setData({
                                isRuleTrue: true
                            })
                        }
                    } else if (item.needReserve == 1 && item.nowOrderStatus == 10) {
                        item.statusNames = '去使用'
                        if (this.data.userInfo && this.data.userInfo.isRealname) {
                            wx.navigateTo({
                                url: '/packageA/pages/indexnian/qrcode/qrcode?cardId=' +
                                    item.cardId + '&productId=' +
                                    item.productId + '&imgCard=' + that.data.cardImage +
                                    '&imgurl=' + item.productImage +
                                    '&productName=' + item.productName +
                                    '&pid_name=' + item.pid_name +
                                    '&productType=' + item.productType,
                            })
                        } else {
                            this.setData({
                                isRuleTrue: true
                            })
                        }
                    } else if (item.nowOrderStatus == 2 && item.needReserve == 0) {
                        item.statusNames = '去核销'
                        wx.navigateTo({
                            url: '/pages/ScenicArea/CardETicket/index?orderNo=' + item.orderNo,
                        })
                    } else if (item.nowOrderStatus == 5 && item.isCommented == 0) {
                        item.statusNames = '去评价'
                        // 商品
                        console.log(item, "66666555554444")
                        wx.navigateTo({
                            url: '/pages/ScenicArea/NianCardOrder/Cardcomment/Cardcomment?orderNo='
                                + item.orderNo
                                + '&storeId=' + item.storeId
                                + '&falg=1'
                            ,
                        })
                    } else if (item.nowOrderStatus == 5 && item.isCommented == 1 && item.needReserve == 0) {
                        item.statusNames = '预约'
                        // 商品
                        console.log(item, "66666555554444")
                        wx.navigateTo({
                            url: '/pages/goYuyue/yuYue/index?productId=' + that.data.objs.productId +
                                '&cardId=' + that.data.objs.cardId +
                                '&productType=' + that.data.objs.productType,
                        })
                    }

                    else if (item.nowOrderStatus == 10 && item.needReserve == 0) {
                        item.statusNames = '预约'
                        wx.navigateTo({
                            url: '/pages/goYuyue/yuYue/index?productId=' + that.data.objs.productId +
                                '&cardId=' + that.data.objs.cardId +
                                '&productType=' + that.data.objs.productType,
                        })
                    } else if (item.nowOrderStatus == null && item.needReserve == 0) {
                        item.statusNames = '预约'
                        wx.navigateTo({
                            url: '/pages/goYuyue/yuYue/index?productId=' + that.data.objs.productId +
                                '&cardId=' + that.data.objs.cardId +
                                '&productType=' + that.data.objs.productType,
                        })
                    } else if (item.nowOrderStatus == null && item.needReserve == 1) {
                        item.statusNames = '去使用'
                        if (this.data.userInfo && this.data.userInfo.isRealname) {

                            wx.navigateTo({
                                url: '/packageA/pages/indexnian/qrcode/qrcode?cardId=' +
                                    item.cardId + '&productId=' +
                                    item.productId + '&imgCard=' + that.data.cardImage +
                                    '&imgurl=' + item.productImage +
                                    '&productName=' + item.productName +
                                    '&pid_name=' + item.pid_name +
                                    '&productType=' + item.productType,
                            })
                        } else {
                            this.checkLoginToJump('/pages/realIdent/index')
                        }
                    }
                    return
                }
                common.showToast('次数已用完')
                return
            }

            if (item.nowOrderStatus == 1 && item.needReserve == 0 ||
                item.nowOrderStatus == 3 && item.needReserve == 0 ||
                item.nowOrderStatus == 6 && item.needReserve == 0 ||
                item.nowOrderStatus == 7 && item.needReserve == 0 ||
                item.nowOrderStatus == 8 && item.needReserve == 0) {
                item.statusNames = '预约'
                wx.navigateTo({
                    url: '/pages/goYuyue/yuYue/index?productId=' + that.data.objs.productId +
                        '&cardId=' + that.data.objs.cardId +
                        '&productType=' + that.data.objs.productType,
                })
            } else if (item.needReserve == 1 && item.nowOrderStatus == 1) {
                item.statusNames = '去使用'
                if (this.data.userInfo && this.data.userInfo.isRealname) {

                    wx.navigateTo({
                        url: '/packageA/pages/indexnian/qrcode/qrcode?cardId=' +
                            item.cardId + '&productId=' +
                            item.productId + '&imgCard=' + that.data.cardImage +
                            '&imgurl=' + item.productImage +
                            '&productName=' + item.productName +
                            '&pid_name=' + item.pid_name +
                            '&productType=' + item.productType,
                    })
                } else {
                    this.setData({
                        isRuleTrue: true
                    })
                }
            } else if (item.needReserve == 1 && item.nowOrderStatus == 10) {
                item.statusNames = '去使用'
                if (this.data.userInfo && this.data.userInfo.isRealname) {

                    wx.navigateTo({
                        url: '/packageA/pages/indexnian/qrcode/qrcode?cardId=' +
                            item.cardId + '&productId=' +
                            item.productId + '&imgCard=' + that.data.cardImage +
                            '&imgurl=' + item.productImage +
                            '&productName=' + item.productName +
                            '&pid_name=' + item.pid_name +
                            '&productType=' + item.productType,
                    })
                } else {
                    this.setData({
                        isRuleTrue: true
                    })
                }
            } else if (item.nowOrderStatus == 2 && item.needReserve == 0) {
                item.statusNames = '去核销'
                wx.navigateTo({
                    url: '/pages/ScenicArea/CardETicket/index?orderNo=' + item.orderNo,
                })
            } else if (item.nowOrderStatus == 5 && item.isCommented == 0) {
                // 门票
                item.statusNames = '去评价'
                console.log(item, "xiuxuixiixixixixixix")
                wx.navigateTo({
                    url: '/pages/ScenicArea/NianCardOrder/Cardcomment/Cardcomment?orderNo='
                        + item.orderNo
                        + '&storeId=' + item.storeId
                        + '&flag=0'
                    ,
                })
            } else if (item.nowOrderStatus == 5 && item.isCommented == 1 && item.needReserve == 0) {
                // 门票
                item.statusNames = '预约'
                console.log(item, "xiuxuixiixixixixixix")
                wx.navigateTo({
                    url: '/pages/goYuyue/yuYue/index?productId=' + that.data.objs.productId +
                        '&cardId=' + that.data.objs.cardId +
                        '&productType=' + that.data.objs.productType,
                })
            }

            else if (item.nowOrderStatus == 10 && item.needReserve == 0) {
                item.statusNames = '预约'
                wx.navigateTo({
                    url: '/pages/goYuyue/yuYue/index?productId=' + that.data.objs.productId +
                        '&cardId=' + that.data.objs.cardId +
                        '&productType=' + that.data.objs.productType,
                })
            } else if (item.nowOrderStatus == null && item.needReserve == 0) {
                item.statusNames = '预约'
                wx.navigateTo({
                    url: '/pages/goYuyue/yuYue/index?productId=' + that.data.objs.productId +
                        '&cardId=' + that.data.objs.cardId +
                        '&productType=' + that.data.objs.productType,
                })
            } else if (item.nowOrderStatus == null && item.needReserve == 1) {
                item.statusNames = '去使用'
                if (this.data.userInfo && this.data.userInfo.isRealname) {
                    wx.navigateTo({
                        url: '/packageA/pages/indexnian/qrcode/qrcode?cardId=' +
                            item.cardId + '&productId=' +
                            item.productId + '&imgCard=' + that.data.cardImage +
                            '&imgurl=' + item.productImage +
                            '&productName=' + item.productName +
                            '&pid_name=' + item.pid_name +
                            '&productType=' + item.productType,
                    })
                } else {
                    this.setData({
                        isRuleTrue: true
                    })
                }
            }
        })
    },
    onShareAppMessage: function () {
        return {
            title: this.data.cardName + '尊享礼遇，只因有你！',
            path: 'packageA/pages/indexnian/indexni?obj=' + this.data.items,
            // imageUrl: 'http://feiyangimage.oss-cn-shanghai.aliyuncs.com/wxApplets/yearCard/year_cardshare.jpg',

            success: (res) => { },
            fail: (res) => {
                // 分享失败
            }
        }
    },
    onShareTimeline() {
        return {
            title: this.data.cardName + '尊享礼遇，只因有你！',
            path: 'packageA/pages/indexnian/indexni?obj=' + this.data.items,
            // imageUrl: 'http://feiyangimage.oss-cn-shanghai.aliyuncs.com/wxApplets/yearCard/year_cardshare.jpg',
            success: (res) => { },
            fail: (res) => {
                // 分享失败
            }
        }
    }

})